#ifndef __SIPSUBSCRIBESESSION2_HPP__
#define __SIPSUBSCRIBESESSION2_HPP__

#include "SipGDServiceConfigure.hpp"
#include "SipDlgSessionBase.hpp"
#include "SipB2BSession.hpp"

#define SUBSCRIBE_EXPIRES 360

namespace wtsip{

class CSipSubscribeSession2;
class CSipSubscription;

class WTGD_SIPSRV_PUBLIC CSipSubscribe2Handle: virtual public CSipSessionHandle
{
public:
	virtual bool onSubscribe(SipMessage& msg, CSipSubscribeSession2& subs) = 0;

	virtual bool onUnsubscribe(SipMessage& msg, CSipSubscribeSession2& subs) = 0;

	virtual bool onNotify(SipMessage& msg, CSipSubscribeSession2& subs) = 0;
};



class WTGD_SIPSRV_PUBLIC CSipSubscribeSession2:
	public CSipDlgSessionBase,
	//public CSipB2BSession,
	public CSipDlgHandle
{
public:
	CSipSubscribeSession2(CSipGDService& sv, CSipSubscription& dlg);

	virtual ~CSipSubscribeSession2();

	resip::Data subscribe(const std::string& contents);

	resip::Data unsubscribe(const std::string& contents);

	resip::Data notify(const std::string& contents);

	virtual bool messageDresser(SipMessage& msg);

	//virtual const resip::Data& getID();

protected:

	/////////////////////////CSipDlgHandle

	virtual bool isFakeTransation(SipMessage& msg, CSipDialogBase& dlg);

	virtual bool onResponse(SipMessage& msg, CSipDialogBase& dlg);

	virtual bool onRequest(SipMessage& msg, CSipDialogBase& dlg);

	virtual bool onTimeout(ApplicationMessage& msg, CSipDialogBase& dlg);

	virtual bool onDestroy(CSipDialogBase& dlg);

	//virtual bool onB2BRequest(SipMessage& request);

	//virtual bool onB2BResponse(const resip::Data& tid, SipMessage& response);

private:

	virtual bool start(const std::string& body);

	//virtual bool stop();

	bool handleSubscribe(SipMessage& msg);

	bool handleUnsubscribe(SipMessage& msg);

	bool handleNotify(SipMessage& msg);

private:

	resip::Data m_subscribeId;

	resip::Data m_unsubscribeId;

};



}//namespace

#endif


